import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { environment } from '@env/environment';
import { LayoutDefaultComponent } from '../layout/default/default.component';
import { LayoutFullScreenComponent } from '../layout/fullscreen/fullscreen.component';
import { LayoutPassportComponent } from '../layout/passport/passport.component';
import { UserLoginComponent } from './passport/login/login.component';
import { AuthGuardService } from '@core/auth/auth-guard.service';
import { HomeComponent } from './home/home.component';
import { LogComponent } from 'app/routes/changelog/log.component';
import {DashboardWorkplaceComponent} from "./dashboard/workplace/workplace.component";
import {DashboardV1Component} from "./dashboard/v1/v1.component";
import {DashboardAnalysisComponent} from "./dashboard/analysis/analysis.component";
import {DashboardMonitorComponent} from "./dashboard/monitor/monitor.component";

const routes: Routes = [
  {
    path: '',
    component: LayoutDefaultComponent,
    canActivate: [AuthGuardService],
    children: [
      { path: '', redirectTo: 'home', pathMatch: 'full' },
      { path: 'home', component: HomeComponent },
      { path: 'dashboard', redirectTo: 'dashboard/v1', pathMatch: 'full' },
      { path: 'dashboard/v1', component: DashboardV1Component },
      { path: 'dashboard/analysis', component: DashboardAnalysisComponent },
      { path: 'dashboard/monitor', component: DashboardMonitorComponent },
      { path: 'dashboard/workplace', component: DashboardWorkplaceComponent },
      { path: 'log', component: LogComponent },
      { path: 'extras', loadChildren: './extras/extras.module#ExtrasModule' },
      { path: 'admin', canActivateChild: [AuthGuardService], loadChildren: './admin/admin.module#AdminModule' },
      { path: 'order', canActivateChild: [AuthGuardService], loadChildren: './order/order.module#OrderModule' },
       { path: 'sys', canActivateChild: [AuthGuardService], loadChildren: './sys/sys.module#SysModule' },
      { path: 'warehouse', canActivateChild: [AuthGuardService], loadChildren: './warehouse/warehouse.module#WarehouseModule'},
      { path: 'workplace', canActivateChild: [AuthGuardService], loadChildren: './workplace/workplace.module#WorkplaceModule'},
      { path: 'report', canActivateChild: [AuthGuardService], loadChildren: './report/report.module#ReportModule'},
      { path: 'spList', canActivateChild: [AuthGuardService], loadChildren: './spList/spList.module#spListModule' },
      { path: 'maList', canActivateChild: [AuthGuardService], loadChildren: './maList/maList.module#maListModule' },
      { path: 'poList', canActivateChild: [AuthGuardService], loadChildren: './poList/poList.module#poListModule' },
      { path: 'fhList', canActivateChild: [AuthGuardService], loadChildren: './fhList/fhList.module#fhListModule' },
      { path: 'blList', canActivateChild: [AuthGuardService], loadChildren: './blList/blList.module#blListModule' },

      { path: 'sysqm',  canActivateChild: [AuthGuardService], loadChildren: './sysqm/sysqm.module#sysqmModule' }

    ],
  },
  {
    path: 'passport',
    component: LayoutPassportComponent,
    children: [
      {
        path: 'login',
        component: UserLoginComponent,
        data: { title: '登录', titleI18n: 'pro-login' },
      },
    ],
  },
  { path: '**', redirectTo: 'home' },
];

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: environment.useHash })],
  exports: [RouterModule],
})
export class RouteRoutingModule {}
